package it.unina.ingswdemo.services;


import java.io.IOException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.google.appengine.api.users.UserService;
import com.google.appengine.api.users.UserServiceFactory;

public class AuthenticationServlet extends HttpServlet {
    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws IOException {
        UserService userService = UserServiceFactory.getUserService();

        
        if (request.getUserPrincipal() != null) {
            response.sendRedirect(userService.createLogoutURL("/welcome.jsf"));
        } else {
            response.sendRedirect(userService.createLoginURL("/welcome.jsf"));
                                         
        }
    }
}